package com.fujimana.android.manacode.converter;

import com.fujimana.android.manacode.utils.Utils;

public abstract class Token {
	
	private String value;
	
	private Options options;

	public Token(String value, Options options) {
		this.options = options;
		
		this.value = replaceTabspace(Utils.escapeHTML(value).replaceAll(" ", "&nbsp;"), getOptions().getTabSize());
	}
	
	private String replaceTabspace(String str, int size) {
		StringBuilder space = new StringBuilder();
		
		for(int i=0; i<size; i++) {
			space.append("&nbsp;");
		}
		
		return str.replaceAll("\\t", space.toString());
	}
	
	public Options getOptions() {
		return options;
	}
	
	public String getType() {
		return this.getClass().getName();
	}
	
	protected String getValue() {
		return value;
	}

	protected void setValue(String value) {
		this.value = value;
	}
	
	public abstract String getFormatedValue();
}
